#include "qtproject.h"
#include "ui_qtproject.h"

#include <Qstring>
#include <QDebug>
Qtproject::Qtproject(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::Qtproject)
{
    ui->setupUi(this);

    initwindow();
    //foodMenu1 = new FoodMenu;
    connect(ui->tablemainframe,&TableFrame::sendTableName,[=](const QString & name){
        ui->tablenumlineEdit->setText(name);
    });
    connect(this,&Qtproject::sendTabelInfo,ui->foodmenu,[=](const QString &tabel_number,const QString & eater_number){
        ui->foodmenu->setTabelNum(tabel_number,eater_number);
    });

    connect(ui->foodmenu,&FoodMenu::sendBackSign,[=](){
        ui->stackedWidget->setCurrentIndex(0);
        ui->backsysbutton->setDisabled(false);
        ui->dinningbutton->setDisabled(false);
        ui->systembutton->setDisabled(false);
        ui->businessbutton->setDisabled(false);
    });
}

Qtproject::~Qtproject()
{
    delete ui;
}

void Qtproject::initwindow()
{
    ui->numberframe->setStyleSheet("QPushButton {\
                                   background-color: #87CEFA;\
            color: white;\
border: none;\
padding: 12px 24px;\
    font-size: 14px;\
    border-radius: 6px;\
}\
QPushButton:hover {\
    background-color: #778899;\
}\
QPushButton:pressed {\
    background-color: #20B2AA\
}"
        );
    ui->orderpushButton->setStyleSheet("QPushButton {\
                                       background-color: #87CEFA;\
            color: white;\
border: none;\
padding: 30px 24px;\
    font-size: 18px;\
    font-weight:bold;\
    border-radius: 30px;\
    text-align:center;\
}\
QPushButton:hover {\
    background-color: #778899;\
}\
QPushButton:pressed {\
    background-color: #20B2AA;\
}"
);
ui->Logolabel->setPixmap(QPixmap(":/icon/logo.webp").scaled(QSize(80,80)));



}

void Qtproject::on_dinningbutton_clicked()
{

    ui->stackedWidget->setCurrentIndex(0);

}

void Qtproject::on_orderpushButton_clicked()
{
    ui->stackedWidget->setCurrentIndex(1);

    QString tabelname = ui->tablenumlineEdit->text();
    QString eaternumber = ui->eaterlineEdit->text();
    emit sendTabelInfo(tabelname,eaternumber);
    ui->backsysbutton->setDisabled(true);
    ui->dinningbutton->setDisabled(true);
    ui->systembutton->setDisabled(true);
    ui->businessbutton->setDisabled(true);
}



void Qtproject::on_pushButton_one_clicked()
{
    QString sendtext =  ui->eaterlineEdit->text();
    ui->eaterlineEdit->clear();
    QString tabletxt = static_cast<QPushButton*>(sender())->text();
    sendtext = sendtext + tabletxt;
    ui->eaterlineEdit->setText(sendtext);

}

void Qtproject::on_pushButton_two_clicked()
{   
    QString sendtext =  ui->eaterlineEdit->text();
    ui->eaterlineEdit->clear();
    QString tabletxt = static_cast<QPushButton*>(sender())->text();
    sendtext = sendtext + tabletxt;
    ui->eaterlineEdit->setText(sendtext);

}

void Qtproject::on_pushButton_three_clicked()
{
    QString sendtext =  ui->eaterlineEdit->text();
    ui->eaterlineEdit->clear();
    QString tabletxt = static_cast<QPushButton*>(sender())->text();
    sendtext = sendtext + tabletxt;
    ui->eaterlineEdit->setText(sendtext);

}

void Qtproject::on_pushButton_four_clicked()
{   
    QString sendtext =  ui->eaterlineEdit->text();
    ui->eaterlineEdit->clear();
    QString tabletxt = static_cast<QPushButton*>(sender())->text();
    sendtext = sendtext + tabletxt;
    ui->eaterlineEdit->setText(sendtext);

}

void Qtproject::on_pushButton_five_clicked()
{   
    QString sendtext =  ui->eaterlineEdit->text();
    ui->eaterlineEdit->clear();
    QString tabletxt = static_cast<QPushButton*>(sender())->text();
    sendtext = sendtext + tabletxt;
    ui->eaterlineEdit->setText(sendtext);

}

void Qtproject::on_pushButton_six_clicked()
{   
    QString sendtext =  ui->eaterlineEdit->text();
    ui->eaterlineEdit->clear();
    QString tabletxt = static_cast<QPushButton*>(sender())->text();
    sendtext = sendtext + tabletxt;
    ui->eaterlineEdit->setText(sendtext);

}

void Qtproject::on_pushButton_eight_clicked()
{    
    QString sendtext =  ui->eaterlineEdit->text();
    ui->eaterlineEdit->clear();

    QString tabletxt = static_cast<QPushButton*>(sender())->text();
    sendtext = sendtext + tabletxt;
    ui->eaterlineEdit->setText(sendtext);

}

void Qtproject::on_pushButton_seven_clicked()
{   
    QString sendtext =  ui->eaterlineEdit->text();
    ui->eaterlineEdit->clear();

    QString tabletxt = static_cast<QPushButton*>(sender())->text();
    sendtext = sendtext + tabletxt;
    ui->eaterlineEdit->setText(sendtext);

}

void Qtproject::on_pushButton_nine_clicked()
{   
    QString sendtext =  ui->eaterlineEdit->text();
    ui->eaterlineEdit->clear();

    QString tabletxt = static_cast<QPushButton*>(sender())->text();
    sendtext = sendtext + tabletxt;
    ui->eaterlineEdit->setText(sendtext);

}

void Qtproject::on_pushButton_zero_clicked()
{    
    QString sendtext =  ui->eaterlineEdit->text();
    ui->eaterlineEdit->clear();

    QString tabletxt = static_cast<QPushButton*>(sender())->text();
    sendtext = sendtext + tabletxt;
    ui->eaterlineEdit->setText(sendtext);

}

void Qtproject::on_pushButton_clicked()
{
    close();
}

void Qtproject::on_businessbutton_clicked()
{
    ui->stackedWidget->setCurrentIndex(2);

}

void Qtproject::on_backsysbutton_clicked()
{
    ui->stackedWidget->setCurrentIndex(3);
}
